/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package base;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
 *
 * @author Tue
 */
public class Queue <E>{
    private List<E> queue;
    Random rand;
    public Queue(){
        queue = new ArrayList<E>();
        rand = new Random(System.currentTimeMillis());
    }
    public boolean isEmpty(){
        return queue.size() == 0;
    }
    public int length(){
        return queue.size();
    }
    public void enqueue(E element){
        queue.add(element);
    }
    public E dequeue(){
        return queue.remove(0);
    }
    public E randomDequeue(){
        int randIndex = rand.nextInt(queue.size());
        return queue.remove(randIndex);
    }

}
